package com.weibo.view;

import java.util.List;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

import com.weibo.sina.R;
import com.weibo.util.MD5;
import com.weibo.util.Util;



public class DirectMessageAdapter  {
	//private List<DirectMessage> mDirectMessageTimeline;
	private int mLayout;
	private Context mContext;
	static final String TAG = "StatusAdapter";
	private ListView mListView;
	
	public DirectMessageAdapter(Context context, int resource, List<String> objects, ListView view) {
		//super(context, resource, objects);
		//mDirectMessageTimeline = objects;
		mLayout = resource;
		mContext = context;
		mListView = view;
	}
	public View getView(int position, View convertView, ViewGroup parent) {
		View row = convertView;
		//DirectMessage data = null;

		if (row == null) {
			LayoutInflater inflater = (LayoutInflater) mContext
					.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

			row = inflater.inflate(mLayout, parent, false);
			// data =mFriendsTimeline.get(position);
			// row.setTag(data);
		} else {
			// data = (Status) row.getTag();
		}
		/*data = mDirectMessageTimeline.get(position);
		TextView tmp = (TextView) row.findViewById(R.id.user_name);
		tmp.setText("@" + data.getSender().getName());
		Util.addLink(tmp, true);

		tmp = (TextView) row.findViewById(R.id.post_time);

		tmp.setText(Util.getPastTime(data.getCreatedAt()));

		tmp = (TextView) row.findViewById(R.id.content);

		tmp.setText(data.getText());
		ImageView imageView =null;
		String key =null;
		Drawable imageDrawable=null;
		Util.addLink(tmp, false);
		

		imageView = (ImageView) row.findViewById(R.id.face);

		key = MD5.getMD5(data.getSender().getProfileImageURL().toString()
				.getBytes());
		imageDrawable = Util.loadImage(key, data.getSender().getProfileImageURL()
				.toString(),getContext(),this);
		if (imageDrawable != null)
			imageView.setBackgroundDrawable(imageDrawable);
		else {
			imageView.setBackgroundResource(R.drawable.face);
		}
		
		*/
		return (row);
	}

}
